<template>
  <div>
    <el-form
      ref="postForm"
      :model="postForm"
      :rules="rules"
      label-width="260px"
      label-suffix=":"
    >
      <sticky :z-index="10" :class-name="'sub-navbar ' + postForm.status">
        <el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">
          保存
        </el-button>
      </sticky>

      <div style="padding: 15px">
        <el-row>
          <el-col :span="22">
            <el-form-item label="会员价格" style="width: 500px">
              <el-input v-model="postForm.price1" />
            </el-form-item>
            <el-form-item label="总代价格" style="width: 500px">
              <el-input v-model="postForm.price2" />
            </el-form-item>
            <el-form-item label="执行总裁价格" style="width: 500px">
              <el-input v-model="postForm.price3" />
            </el-form-item>
            <el-form-item label="执行CEO价格" style="width: 500px">
              <el-input v-model="postForm.price4" />
            </el-form-item>
            <el-form-item label="执行董事价格" style="width: 500px">
              <el-input v-model="postForm.price5" />
            </el-form-item>
            <el-form-item label="总代升级条件2" style="width: 500px">
              <el-input v-model="postForm.recommend1" />
              <span>直推X个明星代言人</span>
            </el-form-item>
            <el-form-item label="总代升级条件2" style="width: 500px">
              <el-input v-model="postForm.team1" />
              <span>团队X个会员</span>
            </el-form-item>
            <el-form-item label="执行总裁升级条件2" style="width: 500px">
              <el-input v-model="postForm.recommend2" />
              <span>直推X个全球总代</span>
            </el-form-item>
            <el-form-item label="执行总裁升级条件2" style="width: 500px">
              <el-input v-model="postForm.team2" />
              <span>团队X个会员</span>
            </el-form-item>
            <el-form-item label="执行CEO升级条件2" style="width: 500px">
              <el-input v-model="postForm.recommend3" />
              <span>直推X个总裁</span>
            </el-form-item>
            <el-form-item label="执行CEO升级条件2" style="width: 500px">
              <el-input v-model="postForm.team3" />
              <span>团队X个会员</span>
            </el-form-item>
            <el-form-item label="执行董事升级条件2" style="width: 500px">
              <el-input v-model="postForm.recommend4" />
              <span>直推X个CEO</span>
            </el-form-item>
            <el-form-item label="执行董事升级条件2" style="width: 500px">
              <el-input v-model="postForm.team4" />
              <span>团队X个会员</span>
            </el-form-item>
            <el-divider />
            <el-form-item label="会员直推奖金" style="width: 500px">
              <el-input v-model="postForm.c1_1" />
            </el-form-item>
            <el-form-item label="明星代言人间推奖金" style="width: 500px">
              <el-input v-model="postForm.c1_2" />
            </el-form-item>
            <el-form-item label="明星代言人平级" style="width: 500px">
              <el-input v-model="postForm.e1" />
              <span>百分比%</span>
            </el-form-item>
            <el-form-item label="总代直推奖金" style="width: 500px">
              <el-input v-model="postForm.c2_1" />
            </el-form-item>
            <el-form-item label="全球总代间推奖金" style="width: 500px">
              <el-input v-model="postForm.c2_2" />
            </el-form-item>
            <el-form-item label="全球总代平级" style="width: 500px">
              <el-input v-model="postForm.e2" />
              <span>百分比%</span>
            </el-form-item>
            <el-form-item label="执行总裁直推奖金" style="width: 500px">
              <el-input v-model="postForm.c3_1" />
            </el-form-item>
            <el-form-item label="总裁间推奖金" style="width: 500px">
              <el-input v-model="postForm.c3_2" />
            </el-form-item>
            <el-form-item label="总裁平级" style="width: 500px">
              <el-input v-model="postForm.e3" />
              <span>百分比%</span>
            </el-form-item>
            <el-form-item label="执行CEO直推奖金" style="width: 500px">
              <el-input v-model="postForm.c4_1" />
            </el-form-item>
            <el-form-item label="CEO间推奖金" style="width: 500px">
              <el-input v-model="postForm.c4_2" />
            </el-form-item>
            <el-form-item label="CEO平级" style="width: 500px">
              <el-input v-model="postForm.e4" />
              <span>百分比%</span>
            </el-form-item>
            <el-form-item label="执行董事直推奖金" style="width: 500px">
              <el-input v-model="postForm.c5_1" />
            </el-form-item>
            <el-form-item label="董事间推奖金" style="width: 500px">
              <el-input v-model="postForm.c5_2" />
            </el-form-item>
            <el-form-item label="董事平级" style="width: 500px">
              <el-input v-model="postForm.e5" />
              <span>百分比%</span>
            </el-form-item>
            <el-divider />
            <!--<h3 style="padding-left: 100px">多少折</h3>-->
            <!--<el-form-item label="会员复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re1" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="明星代言人复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re2" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="总代复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re3" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="全球总代复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re4" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="执行总裁复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re5" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="总裁复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re6" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="执行CEO复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re7" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="CEO复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re8" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="执行董事复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re9" />-->
            <!--</el-form-item>-->
            <!--<el-form-item label="董事复购折扣" style="width: 500px">-->
            <!--  <el-input v-model="postForm.re10" />-->
            <!--</el-form-item>-->
            <!--<el-divider />-->
            <h3 style="padding-left: 100px">比例,按月结算</h3>
            <el-form-item label="运营中心复购分红" style="width: 500px" v-if="false">
              <el-input v-model="postForm.p1" />
            </el-form-item>
            <el-form-item label="运营中心总流水分红" style="width: 500px">
              <el-input v-model="postForm.p2" />
            </el-form-item>
            <el-form-item label="运营中心总流水加权分红" style="width: 500px">
              <el-input v-model="postForm.p3" />
            </el-form-item>
            <el-form-item label="运营中心复购分红1" style="width: 500px">
              <el-input v-model="postForm.new_repeat_start1" />
            </el-form-item>
            <el-form-item label="运营中心复购分红比例1" style="width: 500px">
              <el-input v-model="postForm.new_repeat_ratio1" />
            </el-form-item>
            <el-form-item label="运营中心复购分红2" style="width: 500px">
              <el-input v-model="postForm.new_repeat_start2" />
            </el-form-item>
            <el-form-item label="运营中心复购分红比例2" style="width: 500px">
              <el-input v-model="postForm.new_repeat_ratio2" />
            </el-form-item>
            <el-form-item label="运营中心复购分红3" style="width: 500px">
              <el-input v-model="postForm.new_repeat_start3" />
            </el-form-item>
            <el-form-item label="运营中心复购分红比例3" style="width: 500px">
              <el-input v-model="postForm.new_repeat_ratio3" />
            </el-form-item>
            <el-divider />
            <el-form-item label="德悦股东结算" style="width: 500px">
              <el-input v-model="postForm.g1" />
              <span>进帐金额,百分比%</span>
            </el-form-item>
            <el-form-item label="股东结算" style="width: 500px">
              <el-input value="利润平均分" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

    </el-form>
  </div>
</template>

<script>
import Sticky from '@/components/Sticky'
import api from '@/api'
export default {
  name: 'SystemFlow',
  components: {
    Sticky
  },
  data() {
    return {
      postForm: {
        status: 'draft'
      },
      rules: {
      },
      loading: false
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      const { data } = await api.member.fetchSet()
      this.postForm = Object.assign({}, data)
      this.postForm.status = 'publisher'
    },
    submitForm() {
      this.$refs.postForm.validate(validate => {
        if (validate) {
          this.loading = true
          api.member.saveSet({
            ...this.postForm
          }).then(response => {
            this.$notify({
              title: '成功',
              message: response.message || '保存成功',
              type: 'success',
              duration: 2000
            })
            this.loading = false
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
